Recursive Use of make

Contents|Index|Previous|Next
Recursive use of make

Recursive use of make means using make as a command in a makefile. This technique is useful when you want separate makefiles for various subsystems that compose a larger system. For example, suppose you have a subdirectory, ‘subdir’, which has its own makefile, and you would like the containing directory’s makefile to run make on the subdirectory. You can do it by writing the following declaration.

subsystem:
cd subdir; $(MAKE)

Or, equivalently (see Summary of options), use the following input.

subsystem:
$(MAKE) -C subdir

You can write recursive make commands just by copying this example, but there are many things to know about how they work and why, and about how the sub-make relates to the top-level make.

See the following documentation for more discusssion.

- How the MAKE variable works
- Communicating variables to a sub-make
- Communicating options to a sub-make
- The ‘--print-directory’ option

Top|Contents|Index|Previous|Next